//
// CFunCallbackStream.cpp for CFunCallbackStream in /home/mambou_j//babel-2014
// 
// Made by jacquesquentin mamboumouafo
// Login   <mambou_j@epitech.net>
// 
// Started on  Mon May 14 23:25:55 2012 jacquesquentin mamboumouafo
// Last update Tue May 15 00:02:32 2012 jacquesquentin mamboumouafo
//


#include	"CFunCallbackStream.hpp"
#include	"StreamParameters.hpp"
#include	"Exception.hpp"

namespace	portaudio
{

  CFunCallbackStream::CFunCallbackStream()
  {
  }

  CFunCallbackStream::CFunCallbackStream(const StreamParameters &parameters, PaStreamCallback *funPtr, void *userData)
  {
    open(parameters, funPtr, userData);
  }

  CFunCallbackStream::~CFunCallbackStream()
  {
	try
	  {
	    close();
	  }

	catch (...)
	  {
	  }
  }

  void	CFunCallbackStream::open(const StreamParameters &parameters, PaStreamCallback *funPtr, void *userData)
  {
    PaError	err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), funPtr, userData);

    if (err != paNoError)
      {
	throw PaException(err);
      }
  }
}
